#include <sched.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  pid_t pid;
  int policy;
  struct sched_param sp;

  switch( argv[1][0] ){
  case 'r' :
    policy = SCHED_RR;
    break;
  case 'f' :
    policy = SCHED_FIFO;
    break;
  case 'o' :
    policy = SCHED_OTHER;
    break;
  case 'b' :
    policy = SCHED_BATCH;
    break;
  case 'i' :
    policy = SCHED_IDLE;
    break;
  default:
    printf("Failed to select a policy [rfobi]\n");
    exit(-1);
  }
  sp.sched_priority = atoi(argv[2]);
  pid = atoi(argv[3]);
  if (sched_setscheduler(pid,policy,&sp) == -1)
    printf("sched_setscheduler failed\n");
  return 0;
}
